[EF + Oracle]Object Context

Posted by JTorrecilla on Geeks with Blogs See other posts from Geeks with Blogs or by JTorrecilla
Published on Thu, 03 Mar 2011 14:53:16 GMT Indexed on 2011/03/03 15:25 UTC
Read the original article Hit count: 221

Filed under:

Prologue

After EF episodes I and II, we are going to see the Object Context.

What is Object Context?

It is a class which manages the DB connection, and the different Entities of our model.

When Visual Studio creates the EF model, like I explain previously, also generates a Class that extends ObjectContext.

ObjectContext provides:

- DB connection

- Add, update and delete functions.

- Object Sets of Entities.

- State of Pending Changes.

This class will give a function, for each Entity, like 

Esta clase va a contar con una función, para cada entidad, del tipo “AddTo{ENTITY}({Entity_Type } value)”, which are going to add a Entity to the related ObjectSet.

In addition, it has a property, for each Entity, like “ObjectSet<TEntity> Entity”, does will keep the related record set. It will be filled with the CreateObjectSet<TEntity> function of Base class (ObjectContext).

What is an ObjectSet?

It is a class that allows us to manage the Entity Set from a Type.

It inherits from:

· ObjectQuery<TEntity>

· IObjectSet<TEntity>

· IQueryAble<TEntity

· IEnumerable<TEntity

· IQueryAble

· IEnumerable

An ObjectSet is a class property that allows query, insert, delete and update records from a determinate Entity.

In following chapters we will see how to query Entities.

LazyLoadingEnabled

A very important property of the Context is “LazyLoadingEnabled”. This Boolean property lets indicate if the data loading is lazy, in other words, the Object will not be created and query until not be needed.

Finally

In this post we have seen what the VS generated context is, some of the characteristics, and where to see Entity data.

In next chapters we will see, CRUD operations, and how to query ObjectSets.

© Geeks with Blogs or respective owner